﻿/*
{
"状态":1,
"名称":"获取-角色用户信息",
"作者":"陈泽椿",
"创建时间":"2018-06-30",
"功能":"获取-角色用户信息",
"log": [
	{"date":"06-01" , "dev" :"hzhh" , "content" : ""}
]
}
*/
declare @sql varchar(max)
declare @where varchar(max)
declare @type varchar(max)
declare @role_key int
declare @company_key int

set @role_key = '{role_key}'
set @company_key = '{company_key}'

set @type = '{type}'
set @where = ''
if(@company_key<>'')
begin
	set @where +=' and company_key = '+convert(varchar,@company_key)
end
 
set @where += ' and user_key '+ @type +' (select user_key from y_role_user where role_key = '+convert(varchar,@role_key)+')'

set @sql = 'select user_key,user_name from y_user  where 1=1 {where} '
set @sql =replace(@sql,'{where}',@where)

exec(@sql)
